﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.IO;
using System.Xml.Serialization;

namespace BDSim
{
    /// <summary>
    /// 地面站集合
    /// </summary>
    public class StationCollection : BDSimObject
    {
        #region 字段
        SubGroundSegment _Parent;
        private EStationType _Type;

        [XmlIgnore]
        public SimParam simParam;
        

        //private ObsReceiverInPut ObsInput;
        //private ObsReceiverOutput ObsOutput;

        #region 规划表参量
        
       
        [XmlIgnore]
        public StreamReader sr;
        #endregion

        
        private ObservableCollection<StationBase> _StationList = new ObservableCollection<StationBase>();
        private StationCollectionDataProvider _DataProvider = new StationCollectionDataProvider();      

        #endregion

        #region 属性

        [Browsable(false)]
        public SubGroundSegment Parent
        {
            get { return _Parent; }
            set { _Parent = value;}
        }

        /// <summary>
        /// 地面站类型
        /// </summary>
        [Browsable(true),ReadOnly(true)]
        public EStationType Type
        {
            get { return _Type; }
            set { _Type = value; NotifyPropertyChanged("Type"); }
        }

        /// <summary>
        /// 站名
        /// </summary>
        [ReadOnly(true), Category("基本信息"), Description("")]
        public string Name
        {
            get { return _Name; }
            set { _Name = value; NotifyPropertyChanged("Name"); }
        }       

        /// <summary>
        /// 站列表
        /// </summary>
        [Browsable(false)]
        public ObservableCollection<StationBase> StationList
        {
            get { return _StationList; }
            set { _StationList = value; NotifyPropertyChanged("StationList"); }
        }

        #endregion
        
        #region 构造函数（包含调用方法）

        public StationCollection()
        {
            _DataProvider.Parent = this;
           // this.Parent=;
            _DataProvider.DefineCommand();
            Menu.ItemsSource = _DataProvider.MenuCommandList;
        }

        #endregion

        #region 初始化
        public override void Init()
        {
            string directotyname = Parent.Parent.directotyname;
            base.Init();

            //给_StationList每一个对象（item）赋值
            foreach (var item in _StationList)
            {
                item.Parent = this;
                item.Init();
            }           
        }
        #endregion

        #region 单步运行
        public override void StepRun()
        {
            base.StepRun();
            foreach (var item in StationList)
            {
                item.StepRun();
            }
        }
        #endregion

               

        internal void AddStation(StationBase stationBase)
        {
            stationBase.Parent = this;
            StationList.Add(stationBase);
        }
    }
}
